<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" isErrorPage="true" %>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%> 
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false"%>
<%@ page import="java.util.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<%=request.getContextPath()%>/css/style.css" rel="stylesheet" type="text/css" >
<link href="<%=request.getContextPath()%>/css/button.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/calendar/Calendar1.js" language="javascript"></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/ext/adapter/prototype/prototype.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/classType.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script>

<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/thickbox.js"></script>
<title>MALINI后台管理系统</title>
</head>
<%
	List list =(ArrayList) request.getAttribute("list");
	Object[] obj = (Object[])list.get(0);
 %>		
<script language="javascript"> 
   function querySubClassType(){
   		var pClassType = document.getElementById('bigClass').value;
		if(pClassType == ""){		
			${"midClass"}.options.length=0;		
		}
		else{
			classType.findclassType(pClassType,showback);
		}	
   }
   function showback(classTypeList){
	   DWRUtil.removeAllOptions('midClass');
	   var subClassType = document.getElementById('midClass').value; 
       for(var i=0;i< classTypeList.length;i ++){
       	  var value = classTypeList[i].classCode;
       	  var text = classTypeList[i].classDes;
       	  var option = new Option(text, value);
          document.getElementById('midClass').add(option);
          if(subClassType == text)
       	  {
      	  	option.selected = true;
       	  }
	   }
   }
   
   var rmain = 1; 
   function addMainPic() 
   { 
    var mainT = document.getElementById("mainTable"); 
    var newTR = mainT.insertRow(mainT.rows.length-1); 
    newTR.id = "row" + rmain; 
    var newTD0 = newTR.insertCell(); 
    var newTD1 = newTR.insertCell(); 
    
    newTD1.setAttribute("colSpan","2"); 
    newTD0.innerHTML = "<td class=\"text_1\">颜色：<input name=\"productColor"+ rmain+ "\" type=\"text\" ></td> "; 
    newTD1.innerHTML = "<td class=\"text_1\"><input name=\"file" 
         + rmain 
         + "\" type=\"file\" style=\"width:500px\"> <input name=\"del\" type=\"button\" value=\"删除 \" onClick=\"deleteMain(" + rmain +");\"></td>"; 
    rmain++; 
   } 
   function deleteMain(line) 
   { 
     mainTable.deleteRow(document.getElementById("row" + line).rowIndex); 
   } 
   
   function addOtherColor() 
   { 
    var subT = document.getElementById("subTable"); 
    var newTR = subT.insertRow(subT.rows.length-1); 
    newTR.id = "row" + rmain; 
    var newTD0 = newTR.insertCell(); 
    var newTD1 = newTR.insertCell(); 
    
    newTD1.setAttribute("colSpan","2"); 
    newTD0.innerHTML = "<td style=\"font-size: 10px\">颜色：<input name=\"productColor"+ rmain+ "\" type=\"text\" ></td> "; 
    newTD1.innerHTML = "<td class=\"text_1\"><input name=\"file" 
         + rmain 
         + "\" type=\"file\" style=\"width:500px\"> <input name=\"del\" type=\"button\" value=\"删除 \" onClick=\"deleteOther(" + rmain +");\"></td>"; 
    rmain++; 
   } 
   function deleteOther(line) 
   { 
     subTable.deleteRow(document.getElementById("row" + line).rowIndex); 
   } 
   
   function init(){
   		var status =<%=obj[8]%>;
   		var flag = document.getElementsByName("productStatus");
		if(status=='0'){
			flag[0].checked=true;
		}else if(status=='1'){
			flag[1].checked=true;
		}else if(status=='2'){
			flag[2].checked=true;
		}
		
		var type =<%=obj[9]%>;
   		var flag1 = document.getElementsByName("productType");
		if(type=='0'){
			flag1[0].checked=true;
		}else if(type=='1'){
			flag1[1].checked=true;
		}
		
		var isNew =<%=obj[10]%>;
   		var flag2 = document.getElementsByName("isNew");
		if(type=='0'){
			flag2[0].checked=true;
		}else if(type=='1'){
			flag2[1].checked=true;
		}
		
		var rank =<%=obj[17]%>;
   		var flag3 = document.getElementsByName("rank");
		if(rank=='0'){
			flag3[0].checked=true;
		}else if(rank=='1'){
			flag3[1].checked=true;
		}else if(rank=='2'){
			flag3[2].checked=true;
		}
   }
   
  </script> 

<body bgcolor="#F0F0F0" onload="init()">
<table width="100%" height="32" border="0" cellpadding="0" cellspacing="0" background="<%=request.getContextPath()%>/images/r_1.gif">
  <tr>
    <td width="2%">&nbsp;</td>
    <td width="98%" class="text_1">当前操作：添加商品</td>
  </tr>
</table>
<form name="updForm" method="post" enctype="multipart/form-data">
  <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <TD width="100%" colspan="6">
      <fieldset style="height:100%;">
		<legend class="text_1">基本信息</legend>
	    	<table width="100%">
	    		<tr>
			      <input name="productId" type="hidden" style="width:47%" value="<%=obj[0]%>"/></td>
			    </tr>
			    <tr>
			      <td align="left" valign="middle" class="text_1"  colspan="6" width="100%">产品名称：<input name="productName" type="text" style="width:47%" value="<%=obj[1]%>"/></td>
			    </tr>
			    <tr>
			      <td align="left" valign="middle" class="text_1" colspan="2">产品颜色：<input name="color" type="text" value="<%=obj[2]%>"/></td>
			      <td align="left" valign="middle" class="text_1" colspan="2">产品品牌：<input name="brand" type="text" maxlength="20" value="<%=obj[3]%>"/></td>
			      <td align="left" valign="middle" class="text_1" colspan="2">&nbsp;库存量&nbsp;：<input name="stockNum" type="text" maxlength="20" value="<%=obj[4]%>"/></td>
			    </tr>
			    <tr>
			      <td align="left" valign="middle" class="text_1" colspan="2">主&nbsp;&nbsp;&nbsp;&nbsp;题：<input name="title" type="text" value="<%=obj[5]%>"/></td>
			      <td align="left" valign="middle" class="text_1" colspan="2">系&nbsp;&nbsp;&nbsp;&nbsp;列：<input name="series" type="text" maxlength="20" value="<%=obj[6]%>"/></td>
			      <td align="left" valign="middle" class="text_1" colspan="2">材&nbsp;&nbsp;&nbsp;&nbsp;质：<input name="material" type="text" maxlength="20" value="<%=obj[7]%>"/></td>
			    </tr>
			    <tr>
			      <td align="left" valign="middle" class="text_1" colspan="2">产品状态:
			      <input type="radio" name="productStatus" value="0"/>下架<input type="radio" name="productStatus" value="1" />上架<input type="radio" name="productStatus" value="2" />已售完
			      </td> 
			      <td align="left" valign="middle" class="text_1" colspan="2">产品类型：
			      <input type = "radio" name="productType" value = "0" onclick="TB_show('', '<%=request.getContextPath() %>/pages/backstage/product/DataPass.jsp?TB_iframe=true&height=400&width=800', '')" size="40"/>组合
			      <input type="radio" name="productType" value = "1" />单个
			      </td>
			      <td align="left" valign="middle" class="text_1" colspan="2">是否新品：
			      <input type="radio" name="isNew" value="0"/>不是<input type="radio" name="isNew" value="1" />是
			      </td>
			    </tr>
			    <tr>
			      <td align="left" valign="middle" class="text_1" colspan="6">产品类别：
			      				<select name="bigClassType" id="bigClass" onchange="querySubClassType()">
			      				<c:forEach items="${classList}" var="classType"> 
			      					<option value="${classType.classCode}">${classType.classDes}</option>
			      				</c:forEach>
    							</select>
    							<select name="midClassType" id="midClass" >
    							</select>
    						</td>
			    </tr>
			    <tr>
			      <td align="left" valign="middle" class="text_1" colspan="2">产品编码：<input name="productCode" type="text"  value="<%=obj[13]%>" /></td>
			      <td align="left" valign="middle" class="text_1" colspan="2">产品简码：<input name="productBriefCode" type="text" maxlength="20" value="<%=obj[14]%>"/></td>
			      <td align="left" valign="middle" class="text_1" colspan="2">产品条码：<input name="productBarCode" type="text" maxlength="20" value="<%=obj[15]%>"/></td>
			    </tr>
			    <tr>
			      <td align="left" valign="middle" class="text_1" colspan="6">产&nbsp;&nbsp;&nbsp;&nbsp;地：<input name="areaCode" type="text" style="width:47%" value="<%=obj[16]%>"/></td>
			    </tr>
			    <tr>
			      <td  align="left" valign="middle" class="text_1" colspan="5">产品等级：<input type = "radio" name="rank" value="0"/>优<input type="radio" name="rank" value = "1"/>良<input type="radio" name="rank" value = "2"/>中</td>
			    </tr>
			    <tr>
			      <td align="left" valign="middle" class="text_1" colspan="2">产品尺寸：<input name="size" type="text" value="<%=obj[18]%>"/></td>
			      <td align="left" valign="middle" class="text_1" colspan="2">产品规格：<input name="specCode" type="text" maxlength="20" value="<%=obj[19]%>"/></td>
			      <td align="left" valign="middle" class="text_1" colspan="2">成&nbsp;&nbsp;&nbsp;&nbsp;本：<input name="costPrice" type="text" maxlength="20" value="<%=obj[20]%>"/></td>
			    </tr>
			    <tr>
			      <td align="left" valign="middle" class="text_1" colspan="2">市场价格：<input name="marketPrice" type="text" value="<%=obj[21]%>"/></td>
			      <td align="left" valign="middle" class="text_1" colspan="2">当前售价：<input name="salePrice" type="text" maxlength="20" value="<%=obj[22]%>"/></td>
			      <td align="left" valign="middle" class="text_1" colspan="2">促销价格：<input name="barginPrice" type="text" maxlength="20" value="<%=obj[23]%>"/></td>
			    </tr>
			    <tr>
			      <td align="left" valign="middle" class="text_1" colspan="2">上架日期：<input onfocus="calendar()" name="saleDate" type="text" id="saleDate" value="<%=obj[24]%>"/></td>
			      <td align="left" valign="middle" class="text_1" colspan="4">生产日期：<input onfocus="calendar()" name="produceDate" type="text" id="produceDate" value="<%=obj[25]%>"/></td>
			    </tr>
	    	</table>
	    	</fieldset>
	    	</TD>
	    </tr>
	    <!--  
	    <tr>
	     <TD width="100%" colspan="6">
	      <fieldset style="height:100%;">
			<legend class="text_1">上传主图片</legend>
	      	<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
	       		<tr>
				  <table id="mainTable"> 
				   <tr> 
				     <td>颜色：<input name="mainColor0" type="text"></td> 
				     <td class="text_1"><input type=file name="temp" style="width:500px"><input type="button" name="addMain" value="多图片上传 " onClick="addMainPic()"></td> 
				   </tr> 
				  </table> 
			 	</tr>
	      	 </table>
	       </fieldset>			
	      </TD>
	     </tr>
	     <tr>
	     <TD width="100%" colspan="6">
	      <fieldset style="height:100%;">
			<legend class="text_1">其他颜色</legend>
	      	<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
		      <tr>
				  <table id="subTable"> 
				   <tr> 
				     <td>颜色：<input name="productColor0" type="text"></td> 
				     <td class="text_1"><input type=file name="temp" style="width:500px"><input type="button" name="addOther" value="多图片上传 " onClick="addOtherColor()"></td> 
				   </tr> 
				  </table> 
		    	</tr>
		     </table>
	      </fieldset>		
	      </TD>	
	    </tr>
	    -->
	    <tr>
    	<TD width="100%" colspan="6">
	      <fieldset style="height:100%;">
			<legend class="text_1">产品信息</legend>
	      	<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
	      		<tr><td colspan="6">
					<textarea  name="productInfo" cols="150" rows="8" id="productInfo" style="border: 1 solid #888888;LINE-HEIGHT:18px;padding: 3px;"><%=obj[26]%></textarea>
				</td></tr>
	      	</table>
	      	</fieldset>			
       		</TD>
    	</tr>
    	<tr align="center"><td align="center" colspan=6><input name="Submit1" type="button" value="提   交" onclick="upload()"/></td></tr>
  </table>
</form>
</html>
<script type="text/javascript">
 function upload(){
 	document.updForm.action="/malini/commodityAction.do?op=update";
 	document.updForm.submit();
 }
</script>
<%
	if(request.getAttribute("uploadMsg")!=null){
%>
	<script type="text/javascript">
		alert('<%=request.getAttribute("uploadMsg")%>');
	</script>
<%	
}
%>